package com.sbtr.controller.feature;

import com.sbtr.business.feature.dto.FeMissingRuleDto;
import com.sbtr.business.feature.entity.FeMissingRule;
import com.sbtr.business.feature.service.FeMissingRuleService;
import com.sbtr.common.PageDto;
import com.sbtr.common.Response;
import com.sbtr.controller.common.CommonController;
import com.sbtr.exception.BDException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 缺失值处理字段列表 前端控制器
 *
 * @author dgl
 * @since 2023-03-17
 */
@RestController
@RequestMapping("/feMissingRule")
@Api(tags = "缺失值处理字段列表")
public class FeMissingRuleController extends CommonController<FeMissingRule, FeMissingRuleService> {

    @Autowired
    private FeMissingRuleService feMissingRuleService;

    @GetMapping("/pageList")
    @ApiOperation(httpMethod = "GET", value = "缺失值处理字段列表列表")
    public Response<PageDto<FeMissingRule>> pageList(FeMissingRuleDto feMissingRuleDto){
        return Response.success(feMissingRuleService.pageList(feMissingRuleDto));
    }

    @PostMapping("/save")
    @ApiOperation(httpMethod = "POST", value = "缺失值处理字段列表保存")
    public Response<FeMissingRule> save(@RequestBody FeMissingRule feMissingRule){
        feMissingRule.setId(null);
        if(feMissingRule.insert()){
            return Response.success(feMissingRule);
        }else throw new BDException("保存失败");
    }

}

